Identity Operators
அடையாள ஆபரேட்டர்கள் பொருள்களை ஒப்பிட பயன்படுகின்றன, அவை சமமாக உள்ளதா என்பதை அல்ல, ஆனால் அவை உண்மையில் ஒரே பொருளாக உள்ளதா, ஒரே நினைவக இடத்துடன் உள்ளதா என்பதை:
| Operator | Description | Example |
|---|---|---|
| is | Returns True if both variables are the same object | x is y |
| is not | Returns True if both variables are not the same object | x is not y |
is Operator Examples
is ஆபரேட்டர் இரண்டு மாறிகள் ஒரே பொருளைச் சுட்டிக்காட்டினால் True ஐத் தரும்:
Example
x = ["apple", "banana"]
y = ["apple", "banana"]
z = x
print(x is z)
print(x is y)
print(x == y)
is not Operator Examples
is not ஆபரேட்டர் இரண்டு மாறிகள் ஒரே பொருளைச் சுட்டிக்காட்டாவிட்டால் True ஐத் தரும்:
Example
x = ["apple", "banana"]
y = ["apple", "banana"]
print(x is not y)
Difference Between is and ==
is Operator
இரண்டு மாறிகள் நினைவகத்தில் ஒரே பொருளைச் சுட்டிக்காட்டுகின்றனவா எனச் சரிபார்க்கிறது
== Operator
இரண்டு மாறிகளின் மதிப்புகள் சமமாக உள்ளதா எனச் சரிபார்க்கிறது
Example
x = [1, 2, 3]
y = [1, 2, 3]
print(x == y)
print(x is y)
is Example
a = [1, 2, 3]
b = a # Same object
print(a is b) # True
== Example
a = [1, 2, 3]
b = [1, 2, 3] # Different object
print(a == b) # True
print(a is b) # False
நினைவக காட்சிப்படுத்தல்:
is ஆபரேட்டர் இரண்டு மாறிகள் நினைவகத்தில் ஒரே இடத்தைச் சுட்டிக்காட்டுகின்றனவா எனச் சரிபார்க்கிறது. == ஆபரேட்டர் மதிப்புகளை மட்டுமே ஒப்பிடுகிறது, நினைவக இடத்தை அல்ல.